﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NAccounting
{
    public partial class ProjectActivity
    {
        public bool CanStart() 
        {
            return Appointments.Count == 0 || !Appointments.Any(x => !x.EndMoment.HasValue);
        }

        public bool IsStarted()
        {
            return Appointments.Any(x => !x.EndMoment.HasValue);
        }

        public void Start()
        {
            Appointments.Add(new Appointment { Date = DateTime.Now.Date, StartMoment = DateTime.Now, ProjectActivityId = this.Id });
        }
    }
}